<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>你好</h1>



<style>
    .box{
        width: 200px;
        height: 200px;
        border: 1px solid #000;
        background-color: blue;
    }
</style>

<div class="box" id="box"></div>
<button onclick="test()">清楚定时器</button>


<p id="nav">你是大坏蛋</p>
<button onclick="fun()">点击</button>

<button onclick="getdata()">点击获取数据</button>
</body>
</html>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script>
<script>
    function getdata() {
        $.ajax({
            'url':'https://cnodejs.org/api/v1/topics',
            'success':function (res){
                let str=''
                for(let i=0;i<res.data.length;i++){
                str+=`<p>${res.data[i].title}</p>`
                }
                $('#box').html(str)
            }
        })

    }


    //======================================================
    let arr=[1,2,3,4,5]
    for(let i=0;i<arr.length;i++){
        arr[i]=arr[i]+2
    }
    console.log(arr)

//    function f1(num1,num2) {
//        return num1+num2
//
//    }
//    console.log(f1(3,3))

    let students=[
        {'id':'1','username':'张三','age':18},
        {'id':'2','username':'李四','age':20},
        {"id":"3","username":"王五","age":18}
    ]
    console.log(students[0].id,students[0].username)

    let str3='我是'+students[0].username
    console.log(str3)


  //  =================================


    function fun(){
        //获取标签元素 document.getElementById("元素id的值")
        let p=document.getElementById('nav')
        {#console.log(p)#}

        p.innerHTML='我需要好好的'
        console.log(p)
    }

    //++++++++++++++++++++++++++++++++
    function setcolor() {
        let mybox=document.getElementById('box')
        if (mybox.style.background=='red'){
            mybox.style.background='green'

        }else {
            mybox.style.background='red'
        }

    }
    let interval=setInterval(setcolor,1000)
    function test() {
        alert(0)
        clearInterval(interval)

    }
</script>


